import wepy from 'wepy'
export default class extends wepy.mixin {
    config = {

    }

    data = {
        catesList: [],
        active: 0,
        secondCate: [],
        wh: 0
    }

    methods = {
        onChange(e) {
            console.log(e.detail)
            this.secondCate = this.catesList[e.detail].children
        },

        goGoodsList(cid) {
            wepy.navigateTo({
                url: '/pages/goods_list?cid=' + cid
            })
        }
    }

    async getCatesData() {
        var { data: res } = await wepy.get('/categories')
        console.log(res)
        if (res.meta.status != 200) {
            return wepy.baseToast()
        }
        this.catesList = res.message
        this.secondData = this.catesList[0].children
        this.$apply()
    }

    async getWindowHeight() {
        var res = await wepy.getSystemInfo()
        console.log(res)
        if (res.errMsg == 'getSystemInfo:ok') {
            this.wh = res.windowHeight
            this.$apply()
        }


    }

    onLoad() {
        this.getCatesData(),
            this.getWindowHeight()
    }
}